<?php
require_once '../Model/SafeHaven/OPSafeHaven.php';
require_once '../Model/SafeHaven/OPVirtualCharacter.php';


class SafeHavenWithoutPlayersTest extends PHPUnit_Framework_TestCase {
	
	public function setUp() {
		$this->position = OPPosition::newWithLatitudeLongitude(10, 10);
		$virtualCharacter = new OPVirtualCharacter();
		$this->safeHaven = OPSafeHaven::newWithIdPositionVirtualCharacterAndOwner(1, $this->position, $virtualCharacter, OPFaction::REBELS_FACTION);
	
	}
	
	/**
	 * @test
	 */
	public function safeHavenShouldHaveAnId() {
		$this->assertNotNull($this->safeHaven->id());
		
	}
	
	/**
	 * @test
	 */
	public function safeHavenShouldHaveAnOwner() {
		$this->assertNotNull($this->safeHaven->owner());
		
	}
	
	/**
	 * @test
	 */
	public function playersInShouldBe0() {
		$this->assertEquals(0, $this->safeHaven->playersIn());
		
	}
	
	/**
	 * @test
	 */
	public function safeHavenShouldHaveAPosition() {
		$this->assertEquals($this->position, $this->safeHaven->position());
		
	}
	
	/**
	 * @test
	 */
	public function safeHavenShouldHaveAVirtualCharacter() {
		$this->assertNotNull($this->safeHaven->virtualCharacter());
		
	}
	
	/**
	 * @test
	 */
	public function safeHavenShouldBeCapturedByARebel() {
		$aRebel = new OPRebel();
		$this->safeHaven->isCapturedBy($aRebel);
		
		$this->assertTrue($this->safeHaven->isRebelFaction());
		$this->assertFalse($this->safeHaven->isOppressorFaction());
		
	}
	
	/**
	* @test
	*/
	public function safeHavenShouldBeCapturedByAnOppressorl() {
		$anOppressor = new OPOppressor();
		$this->safeHaven->isCapturedBy($anOppressor);
	
		$this->assertFalse($this->safeHaven->isRebelFaction());
		$this->assertTrue($this->safeHaven->isOppressorFaction());
	
	}
	
	/**
	 * @test
	 */
	public function changeOwnerShouldMakeOppressorsOwners() {
		$this->safeHaven->changeOwner();
		$this->assertEquals(OPFaction::OPPRESSORS_FACTION, $this->safeHaven->owner());
		
	}
	
}